package com.gjs.sso.config;

import com.aliyun.dysmsapi20170525.Client;
import com.aliyun.teaopenapi.models.Config;
import com.gjs.common.manager.notification.INotification;
import com.gjs.common.manager.notification.Notification;
import com.gjs.common.manager.notification.sms.ISms;
import com.gjs.common.manager.notification.sms.Impl.AliyunSms;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class NotificationConfig {

    @Value("${aliyun.sms.access-key-id}")
    private String aliyunSmsAccessKeyId;

    @Value("${aliyun.sms.access-key-secret}")
    private String aliyunSmsAccessKeySecret;

    @Value("${aliyun.sms.endpoint}")
    private String aliyunSmsEndpoint;

    @Bean
    public INotification notification(){
        return new Notification();
    }

    @Bean
    public ISms sms(){
        return new AliyunSms();
    }

    @Bean
    public Client config() throws Exception {
        Config config = new Config()
                // 您的AccessKey ID
                .setAccessKeyId(aliyunSmsAccessKeyId)
                // 您的AccessKey Secret
                .setAccessKeySecret(aliyunSmsAccessKeySecret)
                // 访问的域名
                .setEndpoint(aliyunSmsEndpoint);
        return new Client(config);
    }

}
